<?php $this->placeholder('toolBar')->captureStart();?>

<input type="button" class="button" onclick="window.location.href='<?php echo $this->baseUrl('page/edit/add')?>'" value="Добавить" />
<input type="button" class="button" onclick="deleteSelected();" value="Удалить" />

<div style="float: right;">
        <input type="text" name="query" id="filterQuery" OnKeyPress="applyFilter(this)" style="height: 25px;"/>
        <input type="button" onclick="$('#filterQuery').val('');updateFilter();" class="button" value="Очистить"  />
</div>        
        
<?php $this->placeholder('toolBar')->captureEnd() ?>

<style>
a.glowLink
{
	color:#777777;
}

a.glowLink:hover
{
	color:#19558D;
}
</style>

<script>

function getSelectIds()
{
	var ids = [];
	$(".ids").filter(':checked').each(function (){
			ids.push($(this).val());
		});

	return ids;
}

function deleteSelected()
{
	if ( !confirm('Удалить?') ) return;

	blockUI('Идет удаление...');
	
	var ids = getSelectIds();
	$.post(url('page/edit/remove'), {'ids':ids}, function(){ 
		unBlockUI();
		$(ids).each(function (key, value){
				$("div[id='" + value + "']").fadeOut();
			});
		});
}




function applyFilter(obj)
{
	$(obj).stopTime('filterWaitForInput');
	$(obj).oneTime(1000,'filterWaitForInput', function (){
			updateFilter();
		});
}

function updateFilter()
{
	blockUI('Поиск...');
	$("#pagesContainer").load(url('page/edit/get-filtered-pages'), {'filter':$("#filterQuery").val()}, function (){
		unBlockUI();
		});
}

</script>

<div style="padding: 10px" id="pagesContainer">
<?php 
foreach($this->Pages as $Item)
{
    $editLink = $this->baseUrl('page/edit/edit/id/' . $Item['ID']) ;
?>
<div id="<?=$Item['ID'] ?>" style="margin:5px;font-weight:bold;width: 100%;height: 15px;color:#777777;font-size: 12px;padding-top: 5px">
	<input style="margin-left: 5px; margin-right: 5px" type="checkbox" class="ids" name="ids[]" value="<?= $Item['ID'] ?>" />    <a href="<?=$editLink ?>" class="glowLink"><?= $Item['Title'] ?></a>
</div>
 
<?php 
}
?>
</div>
